package com.znow.admin.system.security.model.convert;

import com.znow.admin.dao.entity.sys.SysPermissionEntity;
import com.znow.admin.dao.entity.sys.SysRolePermissionRelationEntity;
import com.znow.admin.system.security.model.dto.PermissionsTreeDTO;
import com.znow.admin.system.security.model.dto.SysUserDetailsDTO;
import com.znow.admin.system.security.model.res.PermissionRequest;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 系统角色权限与权限转换
 *
 * @author Administrator
 * @date 2022/11/02
 */
@Mapper
public interface SysPermissionsConvert {

    SysPermissionsConvert INSTANCE = Mappers.getMapper(SysPermissionsConvert.class);

    /**
     * 用户dto
     *
     * @param entity 实体
     * @return {@link SysUserDetailsDTO}
     */
    PermissionsTreeDTO toPermissionsDTO(SysPermissionEntity entity);

    /**
     * 对权限dtolist
     *
     * @param permissions 权限
     * @return {@link List}<{@link PermissionsTreeDTO}>
     */
    List<PermissionsTreeDTO> toPermissionsDTOList(List<SysPermissionEntity> permissions);

    /**
     * 系统权限实体
     *
     * @param permissionRequest 权限参数
     * @return {@link SysPermissionEntity}
     */
    SysPermissionEntity toSysPermissionsEntity(PermissionRequest permissionRequest);

    /**
     * 用户dto
     *
     * @param entity 实体
     * @return {@link SysUserDetailsDTO}
     */
    PermissionsTreeDTO toPermissionsDTOByRelation(SysRolePermissionRelationEntity entity);

    /**
     * 对权限dtolist
     *
     * @param permissions 权限
     * @return {@link List}<{@link PermissionsTreeDTO}>
     */
    List<PermissionsTreeDTO> toPermissionsDTOListByRelation(List<SysRolePermissionRelationEntity> permissions);
}
